Skip to content

[main] Bug 648630 Movement Worksheet Creates Incorrect Warehouse Movement for FEFO Lot-Tracked Items - #10924

Merged
MSNehaNawal merged 6 commits into
mainfrom
bugs/Bug-648630-main-MovementWkst_FEFO_LotItemPendingPick
Sep 7, 2026
Merged

[main] Bug 648630 Movement Worksheet Creates Incorrect Warehouse Movement for FEFO Lot-Tracked Items#10924
MSNehaNawal merged 6 commits into
mainfrom
bugs/Bug-648630-main-MovementWkst_FEFO_LotItemPendingPick

Conversation

@MSNehaNawal

@MSNehaNawal MSNehaNawal commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Bug 648630: [master][ALL-E] Movement Worksheet Creates Incorrect Warehouse Movement for FEFO Lot-Tracked Items When Picked-Not-Shipped and Pending Picks Exist. - regression.

Fixes AB#648630

Issue
Movement Worksheet Creates Incorrect Warehouse Movement for FEFO Lot-Tracked Items When Picked-Not-Shipped and Pending Picks Exist.

Root Cause
The availability calculation in CalcTotalAvailQtyToPick (codeunit 7312 "Create Pick") didn't exclude quantity that was already picked but not yet shipped (sitting in an outbound/ship-type bin) or committed to a pending pick. Since a movement can never source stock from the ship zone, this caused the worksheet to select the wrong (FEFO-earliest) lot for the movement — the lot that was already fully committed to outstanding sales orders — instead of the next available lot.

Solution
In CreatePick.Codeunit.al, when called from the Movement Worksheet (CalledFromMoveWksh), subtract the quantity already sitting on outbound bins (WarehouseAvailabilityMgt.CalcQtyOnOutboundBins) from MaxPickableQtyInWhse before it's added to the total available quantity, clamping at zero.

@github-actions github-actions Bot added the Team: SCM GitHub request for SCM area label Sep 2, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix matches the root cause and is covered by a representative regression test.

Pull request overview

Corrects FEFO movement worksheet availability by excluding stock already moved to outbound bins.

Changes:

  • Subtracts outbound-bin quantities from movement availability, clamped at zero.
  • Adds regression coverage for registered and pending picks.
File summaries
File Description
CreatePick.Codeunit.al Corrects movement availability calculation.
SCMMovement.Codeunit.al Adds end-to-end regression test and setup helpers.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@MSNehaNawal
MSNehaNawal marked this pull request as ready for review September 3, 2026 08:44
@MSNehaNawal
MSNehaNawal requested a review from a team September 3, 2026 08:44
@MSNehaNawal
MSNehaNawal requested a review from a team as a code owner September 3, 2026 08:44
Comment thread src/Layers/W1/Tests/SCM-Warehouse/SCMMovement.Codeunit.al
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Request Changes

What this PR does

The change subtracts outbound-bin quantity from directed put-away and pick availability when creating a movement worksheet, and it adds a regression test for FEFO lots with picked-not-shipped and open pick quantities. For replenishing a normal destination bin, this matches the intended rule that a movement must not source stock from outbound bins, and the test covers the reported lot choice.

The implementation is still too broad. It subtracts outbound-bin quantity for every movement worksheet call, but the existing movement-worksheet logic keeps ship-zone destinations exempt from that subtraction.

Problem-solution fit

Fit: Partial

The reported replenishment scenario is clear, and the change handles the picked-not-shipped lot for a normal destination bin. The fix also changes movements whose destination is the ship zone, which is outside the reported problem and does not match the existing availability rule.

Suggestions

S1 (🔴 High): Keep ship-zone movements exempt
Guard the new outbound-bin subtraction with the same ship-zone destination check used by the existing movement path. Without that guard, a directed put-away and pick movement into the ship zone can be shorted by quantity that is already in outbound bins.

Risk assessment and necessity

Risk: The changed code is in CreatePick.Codeunit.al availability calculation for directed put-away and pick movement worksheets. A wrong availability result can create too little movement or no movement for a valid warehouse movement, especially when the destination is the ship zone. The new test covers the reported FEFO replenishment path, and the required checks are passing.

Necessity: The change is needed because movement replenishment should not choose stock that is already picked-not-shipped or committed to another pick. The scope should be narrowed to non-ship destinations so the fix keeps the established ship-zone movement behavior.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10924 round=1 by=alexei-dobriansky at=2026-09-03T12:13:05.9026452Z lastSha=a1e9371421d79d7987905f695b87126d91489128 reviewKey=20bbad9e007f4109c6016a644fe8a6fa02faae1a61dc0399a6c033da3c279ee0 suggestions=S1@d7f6fcb6

Comment thread src/Layers/W1/Tests/SCM-Warehouse/SCMMovement.Codeunit.al
Comment thread src/Layers/W1/Tests/SCM-Warehouse/SCMMovement.Codeunit.al
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 2

Recommendation: Accept

What this PR does

This update narrows the outbound-bin subtraction for movement worksheet availability. It now keeps the subtraction for normal replenishment destinations, but leaves ship-zone movements on the existing path.

The new guard addresses the previous concern. The reported FEFO replenishment case still excludes picked-not-shipped and pending-pick quantity, while destination movements into the ship zone are no longer shorted by outbound-bin stock.

Status of previous suggestions
ID Title Status Author response
S1 Keep ship-zone movements exempt Addressed The latest change adds the ship-zone destination guard before subtracting outbound-bin quantity.
New observations (commits since round 1)

None - the latest change only addresses the previous suggestion.

Risk assessment and necessity

Risk: The touched code is in directed put-away and pick availability for movement worksheets. A wrong result can pick the wrong lot or create the wrong movement quantity, but the subtraction is now scoped away from ship-zone destinations and the regression test covers the reported FEFO lot case.

Necessity: The change is needed because movement replenishment should not choose stock that is already picked-not-shipped or committed to another pick. The scope now matches that need without changing the ship-zone movement rule.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10924 round=2 by=alexei-dobriansky at=2026-09-05T12:19:57.0372653Z lastSha=842116732d7141cc71e703613c428221ada89550 reviewKey=a8a3e093c69f18abeb5a63f1e78970116d243d51a1484d22c7993c93afbccbcb suggestions=S1@d7f6fcb6:addressed parentRound=1

@MSNehaNawal
MSNehaNawal added this pull request to the merge queue Sep 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directed put-away-and-pick movement calculation now excludes tracking-filtered quantity already in outbound bins while preserving movements whose destination is a ship zone. The end-to-end FEFO regression test covers registered picked-not-shipped inventory plus a pending pick and verifies selection of the next available lot at the correct quantity. No blocking concerns found.

Merged via the queue into main with commit b0ddbf3 Sep 7, 2026
172 checks passed
@MSNehaNawal
MSNehaNawal deleted the bugs/Bug-648630-main-MovementWkst_FEFO_LotItemPendingPick branch September 7, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team: SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants